
package net.anzix.jimposition.transformations;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Map;
import javax.swing.JPanel;
import com.lowagie.text.pdf.PdfTemplate;
import net.anzix.jimposition.BasicTransformation;

public class BorderFilter extends AbstractFilter{
    public BorderFilter(){
        setAttribute("padding","0");
    }
    
    
    public String toString() {
        return "Draw border";
    }
    
    public void getPanelSettings() {
        setAttribute("padding","0");
    }
    
    public void process(PdfContentByte cb, PdfWriter writer, PdfReader inputReader, int page) {
        cb.addTemplate(writer.getImportedPage(inputReader, page),1.0f,0f,0f,1.0f,0f,0f);
        int padding=Integer.parseInt((String) getAttribute("padding"));
        cb.rectangle(0+padding,0+padding,getCurrentNewPageSize().width()-padding,getCurrentNewPageSize().height()-padding);
        cb.stroke();
    }

    public JPanel createPanel() {
        return new NoSettingsPanel();
    }
    
}
